package com.asm.blog.controller;

import com.asm.blog.common.lang.Result;
import com.asm.blog.entity.User;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.apache.shiro.authz.annotation.RequiresUser;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestController {

//    @RequiresUser
    @PostMapping("/user")
    public Result user()
    {
        return Result.succ("user权限页面");
    }

//    @RequiresAuthentication
    @PostMapping("/auth")
    public Result auth()
    {
        return Result.succ("auth权限页面");
    }

    @RequiresRoles("admin")
    @PostMapping("/admin")
    public Result admin()
    {
        return Result.succ("admin角色 页面");
    }


    @PostMapping("/anon")
    public Result anon()
    {
        return Result.succ("anon 页面");
    }




    @RequestMapping("/tipLogin")
    public Result needLogin(){

        return Result.fail("登录已失效，请重新登录");

    }



}
